import global, { Skill } from "../../global";

const {ccclass, property} = cc._decorator;

@ccclass
export default class SkillDesc extends cc.Component {

    @property(cc.Label)
    Label_skillDesc:cc.Label = null;        //技能描述
    @property(cc.Label)
    Label_skillCost:cc.Label = null;        //技能花费
    @property(cc.Label)
    Label_skillHold:cc.Label = null;        //技能充能
    @property(cc.Label)
    Label_skillCooling:cc.Label = null;     //技能冷却
    @property(cc.Label)
    Label_skillTime:cc.Label = null;        //技能耐久

    /**
     * UI先有我才有
     */
    start(){
        this.node.active = false;
        global.UI.skillDesc = this;
    }

    /**
     * 打开技能描述框
     */
    openSkillDesc(skill:Skill){
        this.node.active = true;
        this.Label_skillDesc.string = skill.desc;
        this.Label_skillCost.string = `激活：${skill.cost}`;
        this.Label_skillCooling.string = `冷却：${skill.cooling}`;
        this.Label_skillHold.string = `充能：${skill.hold}`;
        if(skill.time<0){
            this.Label_skillTime.string = `耐久：∞`;
        }else{
            this.Label_skillTime.string = `耐久：${skill.time}`;
        }
        
    }

    /**
     * 关闭
     */
    close(){
       this.node.active = false;
    }
}
